<!DOCTYPE html>
<!-- saved from url=(0054)https://github.com/gaussic/text-classification-cnn-rnn -->
<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    
  <link rel="dns-prefetch" href="https://assets-cdn.github.com/">
  <link rel="dns-prefetch" href="https://avatars0.githubusercontent.com/">
  <link rel="dns-prefetch" href="https://avatars1.githubusercontent.com/">
  <link rel="dns-prefetch" href="https://avatars2.githubusercontent.com/">
  <link rel="dns-prefetch" href="https://avatars3.githubusercontent.com/">
  <link rel="dns-prefetch" href="https://github-cloud.s3.amazonaws.com/">
  <link rel="dns-prefetch" href="https://user-images.githubusercontent.com/">



  <link crossorigin="anonymous" href="./GitHub - gaussic_text-classification-cnn-rnn_ CNN-RNN中文文本分类，基于tensorflow_files/frameworks-f27d807afb610bf126cbfb9ce429438a328e012239e5a77fc8152b794553dfc0.css" integrity="sha256-8n2AevthC/Emy/uc5ClDijKOASI55ad/yBUreUVT38A=" media="all" rel="stylesheet">
  <link crossorigin="anonymous" href="./GitHub - gaussic_text-classification-cnn-rnn_ CNN-RNN中文文本分类，基于tensorflow_files/github-90814c795d836404981b54444a6ccc23fac2c6b0e1ce875e90784fbd83445bc5.css" integrity="sha256-kIFMeV2DZASYG1RESmzMI/rCxrDhzodekHhPvYNEW8U=" media="all" rel="stylesheet">
  
  
  <link crossorigin="anonymous" href="./GitHub - gaussic_text-classification-cnn-rnn_ CNN-RNN中文文本分类，基于tensorflow_files/site-784ac435bab892893613aebf8fc79351510fb731a659406e0a2930f7643de45f.css" integrity="sha256-eErENbq4kok2E66/j8eTUVEPtzGmWUBuCikw92Q95F8=" media="all" rel="stylesheet">
  

  <meta name="viewport" content="width=device-width">
  
  <title>GitHub - gaussic/text-classification-cnn-rnn: CNN-RNN中文文本分类，基于tensorflow</title>
  <link rel="search" type="application/opensearchdescription+xml" href="https://github.com/opensearch.xml" title="GitHub">
  <link rel="fluid-icon" href="https://github.com/fluidicon.png" title="GitHub">
  <meta property="fb:app_id" content="1401488693436528">

    
    <meta content="https://avatars1.githubusercontent.com/u/12946979?s=400&amp;v=4" property="og:image"><meta content="GitHub" property="og:site_name"><meta content="object" property="og:type"><meta content="gaussic/text-classification-cnn-rnn" property="og:title"><meta content="https://github.com/gaussic/text-classification-cnn-rnn" property="og:url"><meta content="text-classification-cnn-rnn - CNN-RNN中文文本分类，基于tensorflow" property="og:description">

  <link rel="assets" href="https://assets-cdn.github.com/">
  
  <meta name="pjax-timeout" content="1000">
  
  <meta name="request-id" content="1A23:218B9:28352C5:356E436:5A4F8077" data-pjax-transient="">
  

  <meta name="selected-link" value="repo_source" data-pjax-transient="">

    <meta name="google-site-verification" content="KT5gs8h0wvaagLKAVWq8bbeNwnZZK1r1XQysX3xurLU">
  <meta name="google-site-verification" content="ZzhVyEFwb7w3e0-uOTltm8Jsck2F5StVihD0exw2fsA">
  <meta name="google-site-verification" content="GXs5KoUUkNCoaAZn7wPN-t01Pywp9M3sEjnt_3_ZWPc">
    <meta name="google-analytics" content="UA-3769691-2">

<meta content="collector.githubapp.com" name="octolytics-host"><meta content="github" name="octolytics-app-id"><meta content="https://collector.githubapp.com/github-external/browser_event" name="octolytics-event-url"><meta content="1A23:218B9:28352C5:356E436:5A4F8077" name="octolytics-dimension-request_id"><meta content="sea" name="octolytics-dimension-region_edge"><meta content="iad" name="octolytics-dimension-region_render">
<meta content="/&lt;user-name&gt;/&lt;repo-name&gt;" data-pjax-transient="true" name="analytics-location">




  <meta class="js-ga-set" name="dimension1" content="Logged Out">


  

      <meta name="hostname" content="github.com">
  <meta name="user-login" content="">

      <meta name="expected-hostname" content="github.com">
    <meta name="js-proxy-site-detection-payload" content="NDdhZjczM2ZkODM5ZjU3MjAxYzlhNDQ2OTU5NjQzNmVjODNmOTRlNzQ0MjI4NTQzNGQ5ODZjZmQ0MGQ1YjYxOXx7InJlbW90ZV9hZGRyZXNzIjoiMTE3LjE4Ny4xMS4xNTMiLCJyZXF1ZXN0X2lkIjoiMUEyMzoyMThCOToyODM1MkM1OjM1NkU0MzY6NUE0RjgwNzciLCJ0aW1lc3RhbXAiOjE1MTUxNTk2NzEsImhvc3QiOiJnaXRodWIuY29tIn0=">


  <meta name="html-safe-nonce" content="6088c79e6a53d525b05357e85683a9d996bdbfea">

  <meta http-equiv="x-pjax-version" content="33fde39efb62989e9022eefd6d69d17a">
  

      <link href="https://github.com/gaussic/text-classification-cnn-rnn/commits/master.atom" rel="alternate" title="Recent Commits to text-classification-cnn-rnn:master" type="application/atom+xml">

  <meta name="description" content="text-classification-cnn-rnn - CNN-RNN中文文本分类，基于tensorflow">
  <meta name="go-import" content="github.com/gaussic/text-classification-cnn-rnn git https://github.com/gaussic/text-classification-cnn-rnn.git">

  <meta content="12946979" name="octolytics-dimension-user_id"><meta content="gaussic" name="octolytics-dimension-user_login"><meta content="101607701" name="octolytics-dimension-repository_id"><meta content="gaussic/text-classification-cnn-rnn" name="octolytics-dimension-repository_nwo"><meta content="true" name="octolytics-dimension-repository_public"><meta content="false" name="octolytics-dimension-repository_is_fork"><meta content="101607701" name="octolytics-dimension-repository_network_root_id"><meta content="gaussic/text-classification-cnn-rnn" name="octolytics-dimension-repository_network_root_nwo"><meta content="false" name="octolytics-dimension-repository_explore_github_marketplace_ci_cta_shown">


    <link rel="canonical" href="https://github.com/gaussic/text-classification-cnn-rnn" data-pjax-transient="">


  <meta name="browser-stats-url" content="https://api.github.com/_private/browser/stats">

  <meta name="browser-errors-url" content="https://api.github.com/_private/browser/errors">

  <link rel="mask-icon" href="https://assets-cdn.github.com/pinned-octocat.svg" color="#000000">
  <link rel="icon" type="image/x-icon" class="js-site-favicon" href="https://assets-cdn.github.com/favicon.ico">

<meta name="theme-color" content="#1e2327">


  <meta name="u2f-support" content="true">

  </head>

  <body class="logged-out env-production">
    

  <div class="position-relative js-header-wrapper ">
    <a href="https://github.com/gaussic/text-classification-cnn-rnn#start-of-content" tabindex="1" class="px-2 py-4 show-on-focus js-skip-to-content">Skip to content</a>
    <div id="js-pjax-loader-bar" class="pjax-loader-bar"><div class="progress"></div></div>

    
    
    
      



        <header class="Header header-logged-out  position-relative f4 py-3" role="banner">
  <div class="container-lg d-flex px-3">
    <div class="d-flex flex-justify-between flex-items-center">
      <a class="header-logo-invertocat my-0" href="https://github.com/" aria-label="Homepage" data-ga-click="(Logged out) Header, go to homepage, icon:logo-wordmark">
        <svg aria-hidden="true" class="octicon octicon-mark-github" height="32" version="1.1" viewBox="0 0 16 16" width="32"><path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z"></path></svg>
      </a>

    </div>

    <div class="HeaderMenu HeaderMenu--bright d-flex flex-justify-between flex-auto">
        <nav class="mt-0">
          <ul class="d-flex list-style-none">
              <li class="ml-2">
                <a href="https://github.com/features" class="js-selected-navigation-item HeaderNavlink px-0 py-2 m-0" data-ga-click="Header, click, Nav menu - item:features" data-selected-links="/features /features/project-management /features/code-review /features/project-management /features/integrations /features">
                  Features
</a>              </li>
              <li class="ml-4">
                <a href="https://github.com/business" class="js-selected-navigation-item HeaderNavlink px-0 py-2 m-0" data-ga-click="Header, click, Nav menu - item:business" data-selected-links="/business /business/security /business/customers /business">
                  Business
</a>              </li>

              <li class="ml-4">
                <a href="https://github.com/explore" class="js-selected-navigation-item HeaderNavlink px-0 py-2 m-0" data-ga-click="Header, click, Nav menu - item:explore" data-selected-links="/explore /trending /trending/developers /integrations /integrations/feature/code /integrations/feature/collaborate /integrations/feature/ship showcases showcases_search showcases_landing /explore">
                  Explore
</a>              </li>

              <li class="ml-4">
                    <a href="https://github.com/marketplace" class="js-selected-navigation-item HeaderNavlink px-0 py-2 m-0" data-ga-click="Header, click, Nav menu - item:marketplace" data-selected-links=" /marketplace">
                      Marketplace
</a>              </li>
              <li class="ml-4">
                <a href="https://github.com/pricing" class="js-selected-navigation-item HeaderNavlink px-0 py-2 m-0" data-ga-click="Header, click, Nav menu - item:pricing" data-selected-links="/pricing /pricing/developer /pricing/team /pricing/business-hosted /pricing/business-enterprise /pricing">
                  Pricing
</a>              </li>
          </ul>
        </nav>

      <div class="d-flex">
          <div class="d-lg-flex flex-items-center mr-3">
            <div class="header-search scoped-search site-scoped-search js-site-search" role="search">
  <!-- '"` --><!-- </textarea></xmp> --><form accept-charset="UTF-8" action="https://github.com/gaussic/text-classification-cnn-rnn/search" class="js-site-search-form" data-scoped-search-url="/gaussic/text-classification-cnn-rnn/search" data-unscoped-search-url="/search" method="get"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓"></div>
    <label class="form-control header-search-wrapper js-chromeless-input-container">
        <a href="https://github.com/gaussic/text-classification-cnn-rnn" class="header-search-scope no-underline">This repository</a>
      <input type="text" class="form-control header-search-input js-site-search-focus js-site-search-field is-clearable" data-hotkey="s" name="q" value="" placeholder="Search" aria-label="Search this repository" data-unscoped-placeholder="Search GitHub" data-scoped-placeholder="Search" autocapitalize="off">
        <input type="hidden" class="js-site-search-type-field" name="type">
    </label>
</form></div>

          </div>

        <span class="d-inline-block">
            <div class="HeaderNavlink px-0 py-2 m-0">
              <a class="text-bold text-white no-underline" href="https://github.com/login?return_to=%2Fgaussic%2Ftext-classification-cnn-rnn" data-ga-click="(Logged out) Header, clicked Sign in, text:sign-in">Sign in</a>
                <span class="text-gray">or</span>
                <a class="text-bold text-white no-underline" href="https://github.com/join?source=header-repo" data-ga-click="(Logged out) Header, clicked Sign up, text:sign-up">Sign up</a>
            </div>
        </span>
      </div>
    </div>
  </div>
</header>

  </div>

  <div id="start-of-content" class="show-on-focus"></div>

    <div id="js-flash-container">
</div>



  <div role="main">
        <div itemscope="" itemtype="http://schema.org/SoftwareSourceCode" class="">
    <div id="js-repo-pjax-container" data-pjax-container="">
      





  <div class="pagehead repohead instapaper_ignore readability-menu experiment-repo-nav  ">
    <div class="repohead-details-container clearfix container">

      <ul class="pagehead-actions">
  <li>
      <a href="https://github.com/login?return_to=%2Fgaussic%2Ftext-classification-cnn-rnn" class="btn btn-sm btn-with-count tooltipped tooltipped-n" aria-label="You must be signed in to watch a repository" rel="nofollow">
    <svg aria-hidden="true" class="octicon octicon-eye" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M8.06 2C3 2 0 8 0 8s3 6 8.06 6C13 14 16 8 16 8s-3-6-7.94-6zM8 12c-2.2 0-4-1.78-4-4 0-2.2 1.8-4 4-4 2.22 0 4 1.8 4 4 0 2.22-1.78 4-4 4zm2-4c0 1.11-.89 2-2 2-1.11 0-2-.89-2-2 0-1.11.89-2 2-2 1.11 0 2 .89 2 2z"></path></svg>
    Watch
  </a>
  <a class="social-count" href="https://github.com/gaussic/text-classification-cnn-rnn/watchers" aria-label="24 users are watching this repository">
    24
  </a>

  </li>

  <li>
      <a href="https://github.com/login?return_to=%2Fgaussic%2Ftext-classification-cnn-rnn" class="btn btn-sm btn-with-count tooltipped tooltipped-n" aria-label="You must be signed in to star a repository" rel="nofollow">
    <svg aria-hidden="true" class="octicon octicon-star" height="16" version="1.1" viewBox="0 0 14 16" width="14"><path fill-rule="evenodd" d="M14 6l-4.9-.64L7 1 4.9 5.36 0 6l3.6 3.26L2.67 14 7 11.67 11.33 14l-.93-4.74z"></path></svg>
    Star
  </a>

    <a class="social-count js-social-count" href="https://github.com/gaussic/text-classification-cnn-rnn/stargazers" aria-label="251 users starred this repository">
      251
    </a>

  </li>

  <li>
      <a href="https://github.com/login?return_to=%2Fgaussic%2Ftext-classification-cnn-rnn" class="btn btn-sm btn-with-count tooltipped tooltipped-n" aria-label="You must be signed in to fork a repository" rel="nofollow">
        <svg aria-hidden="true" class="octicon octicon-repo-forked" height="16" version="1.1" viewBox="0 0 10 16" width="10"><path fill-rule="evenodd" d="M8 1a1.993 1.993 0 0 0-1 3.72V6L5 8 3 6V4.72A1.993 1.993 0 0 0 2 1a1.993 1.993 0 0 0-1 3.72V6.5l3 3v1.78A1.993 1.993 0 0 0 5 15a1.993 1.993 0 0 0 1-3.72V9.5l3-3V4.72A1.993 1.993 0 0 0 8 1zM2 4.2C1.34 4.2.8 3.65.8 3c0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zm3 10c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zm3-10c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2z"></path></svg>
        Fork
      </a>

    <a href="https://github.com/gaussic/text-classification-cnn-rnn/network" class="social-count" aria-label="122 users forked this repository">
      122
    </a>
  </li>
</ul>

      <h1 class="public ">
  <svg aria-hidden="true" class="octicon octicon-repo" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path fill-rule="evenodd" d="M4 9H3V8h1v1zm0-3H3v1h1V6zm0-2H3v1h1V4zm0-2H3v1h1V2zm8-1v12c0 .55-.45 1-1 1H6v2l-1.5-1.5L3 16v-2H1c-.55 0-1-.45-1-1V1c0-.55.45-1 1-1h10c.55 0 1 .45 1 1zm-1 10H1v2h2v-1h3v1h5v-2zm0-10H2v9h9V1z"></path></svg>
  <span class="author" itemprop="author"><a href="https://github.com/gaussic" class="url fn" rel="author">gaussic</a></span><!--
--><span class="path-divider">/</span><!--
--><strong itemprop="name"><a href="https://github.com/gaussic/text-classification-cnn-rnn" data-pjax="#js-repo-pjax-container">text-classification-cnn-rnn</a></strong>

</h1>

    </div>
    
<nav class="reponav js-repo-nav js-sidenav-container-pjax container" itemscope="" itemtype="http://schema.org/BreadcrumbList" role="navigation" data-pjax="#js-repo-pjax-container">

  <span itemscope="" itemtype="http://schema.org/ListItem" itemprop="itemListElement">
    <a href="https://github.com/gaussic/text-classification-cnn-rnn" class="js-selected-navigation-item selected reponav-item" data-hotkey="g c" data-selected-links="repo_source repo_downloads repo_commits repo_releases repo_tags repo_branches repo_packages /gaussic/text-classification-cnn-rnn" itemprop="url">
      <svg aria-hidden="true" class="octicon octicon-code" height="16" version="1.1" viewBox="0 0 14 16" width="14"><path fill-rule="evenodd" d="M9.5 3L8 4.5 11.5 8 8 11.5 9.5 13 14 8 9.5 3zm-5 0L0 8l4.5 5L6 11.5 2.5 8 6 4.5 4.5 3z"></path></svg>
      <span itemprop="name">Code</span>
      <meta itemprop="position" content="1">
</a>  </span>

    <span itemscope="" itemtype="http://schema.org/ListItem" itemprop="itemListElement">
      <a href="https://github.com/gaussic/text-classification-cnn-rnn/issues" class="js-selected-navigation-item reponav-item" data-hotkey="g i" data-selected-links="repo_issues repo_labels repo_milestones /gaussic/text-classification-cnn-rnn/issues" itemprop="url">
        <svg aria-hidden="true" class="octicon octicon-issue-opened" height="16" version="1.1" viewBox="0 0 14 16" width="14"><path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg>
        <span itemprop="name">Issues</span>
        <span class="Counter">1</span>
        <meta itemprop="position" content="2">
</a>    </span>

  <span itemscope="" itemtype="http://schema.org/ListItem" itemprop="itemListElement">
    <a href="https://github.com/gaussic/text-classification-cnn-rnn/pulls" class="js-selected-navigation-item reponav-item" data-hotkey="g p" data-selected-links="repo_pulls /gaussic/text-classification-cnn-rnn/pulls" itemprop="url">
      <svg aria-hidden="true" class="octicon octicon-git-pull-request" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path fill-rule="evenodd" d="M11 11.28V5c-.03-.78-.34-1.47-.94-2.06C9.46 2.35 8.78 2.03 8 2H7V0L4 3l3 3V4h1c.27.02.48.11.69.31.21.2.3.42.31.69v6.28A1.993 1.993 0 0 0 10 15a1.993 1.993 0 0 0 1-3.72zm-1 2.92c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zM4 3c0-1.11-.89-2-2-2a1.993 1.993 0 0 0-1 3.72v6.56A1.993 1.993 0 0 0 2 15a1.993 1.993 0 0 0 1-3.72V4.72c.59-.34 1-.98 1-1.72zm-.8 10c0 .66-.55 1.2-1.2 1.2-.65 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2zM2 4.2C1.34 4.2.8 3.65.8 3c0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2z"></path></svg>
      <span itemprop="name">Pull requests</span>
      <span class="Counter">0</span>
      <meta itemprop="position" content="3">
</a>  </span>

    <a href="https://github.com/gaussic/text-classification-cnn-rnn/projects" class="js-selected-navigation-item reponav-item" data-hotkey="g b" data-selected-links="repo_projects new_repo_project repo_project /gaussic/text-classification-cnn-rnn/projects">
      <svg aria-hidden="true" class="octicon octicon-project" height="16" version="1.1" viewBox="0 0 15 16" width="15"><path fill-rule="evenodd" d="M10 12h3V2h-3v10zm-4-2h3V2H6v8zm-4 4h3V2H2v12zm-1 1h13V1H1v14zM14 0H1a1 1 0 0 0-1 1v14a1 1 0 0 0 1 1h13a1 1 0 0 0 1-1V1a1 1 0 0 0-1-1z"></path></svg>
      Projects
      <span class="Counter">0</span>
</a>


  <a href="https://github.com/gaussic/text-classification-cnn-rnn/pulse" class="js-selected-navigation-item reponav-item" data-selected-links="repo_graphs repo_contributors dependency_graph pulse /gaussic/text-classification-cnn-rnn/pulse">
    <svg aria-hidden="true" class="octicon octicon-graph" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M16 14v1H0V0h1v14h15zM5 13H3V8h2v5zm4 0H7V3h2v10zm4 0h-2V6h2v7z"></path></svg>
    Insights
</a>

</nav>


  </div>

<div class="container new-discussion-timeline experiment-repo-nav ">
  <div class="repository-content ">

    
      <div class="signup-prompt-bg rounded-1">
      <div class="signup-prompt p-4 text-center mb-4 rounded-1">
        <div class="position-relative">
          <!-- '"` --><!-- </textarea></xmp> --><form accept-charset="UTF-8" action="https://github.com/site/dismiss_signup_prompt" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓"><input name="authenticity_token" type="hidden" value="7BSrKxDkLEYRP2sOFCPwwLP6U9/jDKqWQKGNIKVAW1kqB/fb4+gHQHq490c15BkewbCwSZu0RRnRTnrNNlax5w=="></div>
            <button type="submit" class="position-absolute top-0 right-0 btn-link link-gray" data-ga-click="(Logged out) Sign up prompt, clicked Dismiss, text:dismiss">
              Dismiss
            </button>
</form>
          <h3 class="pt-2">Join GitHub today</h3>
          <p class="col-6 mx-auto">GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.</p>
          <p class="pb-2">
            <a class="btn btn-blue" href="https://github.com/join?source=prompt-code" data-ga-click="(Logged out) Sign up prompt, clicked Sign up, text:sign-up">Sign up</a>
          </p>
        </div>
      </div>
    </div>


  <div class="js-repo-meta-container">
  <div class="repository-meta mb-0  js-repo-meta-edit js-details-container ">
    <div class="repository-meta-content col-11 mb-1">
          <span class="col-11 text-gray-dark mr-2" itemprop="about">
            CNN-RNN中文文本分类，基于tensorflow
          </span>
    </div>

  </div>

    <div class="mb-3 repository-topics-container js-repository-topics-container js-details-container">
      <div id="topics-list-container" data-url="/gaussic/text-classification-cnn-rnn/settings/topics">
          <div class="list-topics-container f6 mt-1">
      <a href="https://github.com/topics/tensorflow" class="topic-tag topic-tag-link" data-ga-click="Topic, repository page" data-octo-click="topic_click" data-octo-dimensions="topic:tensorflow">
        tensorflow
      </a>
      <a href="https://github.com/topics/cnn" class="topic-tag topic-tag-link" data-ga-click="Topic, repository page" data-octo-click="topic_click" data-octo-dimensions="topic:cnn">
        cnn
      </a>
      <a href="https://github.com/topics/text-classification" class="topic-tag topic-tag-link" data-ga-click="Topic, repository page" data-octo-click="topic_click" data-octo-dimensions="topic:text-classification">
        text-classification
      </a>
      <a href="https://github.com/topics/chinese" class="topic-tag topic-tag-link" data-ga-click="Topic, repository page" data-octo-click="topic_click" data-octo-dimensions="topic:chinese">
        chinese
      </a>
      <a href="https://github.com/topics/classification" class="topic-tag topic-tag-link" data-ga-click="Topic, repository page" data-octo-click="topic_click" data-octo-dimensions="topic:classification">
        classification
      </a>
      <a href="https://github.com/topics/rnn" class="topic-tag topic-tag-link" data-ga-click="Topic, repository page" data-octo-click="topic_click" data-octo-dimensions="topic:rnn">
        rnn
      </a>
      <a href="https://github.com/topics/tensorboard" class="topic-tag topic-tag-link" data-ga-click="Topic, repository page" data-octo-click="topic_click" data-octo-dimensions="topic:tensorboard">
        tensorboard
      </a>
  </div>


      </div>

    </div>
</div>



  <div class="overall-summary overall-summary-bottomless">
    <div class="stats-switcher-viewport js-stats-switcher-viewport">
      <div class="stats-switcher-wrapper">
      <ul class="numbers-summary">
        <li class="commits">
          <a data-pjax="" href="https://github.com/gaussic/text-classification-cnn-rnn/commits/master">
              <svg aria-hidden="true" class="octicon octicon-history" height="16" version="1.1" viewBox="0 0 14 16" width="14"><path fill-rule="evenodd" d="M8 13H6V6h5v2H8v5zM7 1C4.81 1 2.87 2.02 1.59 3.59L0 2v4h4L2.5 4.5C3.55 3.17 5.17 2.3 7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-.34.03-.67.09-1H.08C.03 7.33 0 7.66 0 8c0 3.86 3.14 7 7 7s7-3.14 7-7-3.14-7-7-7z"></path></svg>
              <span class="num text-emphasized">
                47
              </span>
              commits
          </a>
        </li>
        <li>
          <a data-pjax="" href="https://github.com/gaussic/text-classification-cnn-rnn/branches">
            <svg aria-hidden="true" class="octicon octicon-git-branch" height="16" version="1.1" viewBox="0 0 10 16" width="10"><path fill-rule="evenodd" d="M10 5c0-1.11-.89-2-2-2a1.993 1.993 0 0 0-1 3.72v.3c-.02.52-.23.98-.63 1.38-.4.4-.86.61-1.38.63-.83.02-1.48.16-2 .45V4.72a1.993 1.993 0 0 0-1-3.72C.88 1 0 1.89 0 3a2 2 0 0 0 1 1.72v6.56c-.59.35-1 .99-1 1.72 0 1.11.89 2 2 2 1.11 0 2-.89 2-2 0-.53-.2-1-.53-1.36.09-.06.48-.41.59-.47.25-.11.56-.17.94-.17 1.05-.05 1.95-.45 2.75-1.25S8.95 7.77 9 6.73h-.02C9.59 6.37 10 5.73 10 5zM2 1.8c.66 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2C1.35 4.2.8 3.65.8 3c0-.65.55-1.2 1.2-1.2zm0 12.41c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zm6-8c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2z"></path></svg>
            <span class="num text-emphasized">
              1
            </span>
            branch
          </a>
        </li>

        <li>
          <a href="https://github.com/gaussic/text-classification-cnn-rnn/releases">
            <svg aria-hidden="true" class="octicon octicon-tag" height="16" version="1.1" viewBox="0 0 14 16" width="14"><path fill-rule="evenodd" d="M7.73 1.73C7.26 1.26 6.62 1 5.96 1H3.5C2.13 1 1 2.13 1 3.5v2.47c0 .66.27 1.3.73 1.77l6.06 6.06c.39.39 1.02.39 1.41 0l4.59-4.59a.996.996 0 0 0 0-1.41L7.73 1.73zM2.38 7.09c-.31-.3-.47-.7-.47-1.13V3.5c0-.88.72-1.59 1.59-1.59h2.47c.42 0 .83.16 1.13.47l6.14 6.13-4.73 4.73-6.13-6.15zM3.01 3h2v2H3V3h.01z"></path></svg>
            <span class="num text-emphasized">
              0
            </span>
            releases
          </a>
        </li>

        <li>
            <a href="https://github.com/gaussic/text-classification-cnn-rnn/graphs/contributors">
  <svg aria-hidden="true" class="octicon octicon-organization" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M16 12.999c0 .439-.45 1-1 1H7.995c-.539 0-.994-.447-.995-.999H1c-.54 0-1-.561-1-1 0-2.634 3-4 3-4s.229-.409 0-1c-.841-.621-1.058-.59-1-3 .058-2.419 1.367-3 2.5-3s2.442.58 2.5 3c.058 2.41-.159 2.379-1 3-.229.59 0 1 0 1s1.549.711 2.42 2.088C9.196 9.369 10 8.999 10 8.999s.229-.409 0-1c-.841-.62-1.058-.59-1-3 .058-2.419 1.367-3 2.5-3s2.437.581 2.495 3c.059 2.41-.158 2.38-1 3-.229.59 0 1 0 1s3.005 1.366 3.005 4"></path></svg>
    <span class="num text-emphasized">
      1
    </span>
    contributor
</a>

        </li>
          <li>
            <a href="https://github.com/gaussic/text-classification-cnn-rnn/blob/master/LICENSE">
              <svg aria-hidden="true" class="octicon octicon-law" height="16" version="1.1" viewBox="0 0 14 16" width="14"><path fill-rule="evenodd" d="M7 4c-.83 0-1.5-.67-1.5-1.5S6.17 1 7 1s1.5.67 1.5 1.5S7.83 4 7 4zm7 6c0 1.11-.89 2-2 2h-1c-1.11 0-2-.89-2-2l2-4h-1c-.55 0-1-.45-1-1H8v8c.42 0 1 .45 1 1h1c.42 0 1 .45 1 1H3c0-.55.58-1 1-1h1c0-.55.58-1 1-1h.03L6 5H5c0 .55-.45 1-1 1H3l2 4c0 1.11-.89 2-2 2H2c-1.11 0-2-.89-2-2l2-4H1V5h3c0-.55.45-1 1-1h4c.55 0 1 .45 1 1h3v1h-1l2 4zM2.5 7L1 10h3L2.5 7zM13 10l-1.5-3-1.5 3h3z"></path></svg>
                MIT
            </a>
          </li>
      </ul>

        <div class="repository-lang-stats">
          <ol class="repository-lang-stats-numbers">
            <li>
                <a href="https://github.com/gaussic/text-classification-cnn-rnn/search?l=python" data-ga-click="Repository, language stats search click, location:repo overview">
                  <span class="color-block language-color" style="background-color:#3572A5;"></span>
                  <span class="lang">Python</span>
                  <span class="percent">98.3%</span>
                </a>
            </li>
            <li>
                <a href="https://github.com/gaussic/text-classification-cnn-rnn/search?l=shell" data-ga-click="Repository, language stats search click, location:repo overview">
                  <span class="color-block language-color" style="background-color:#89e051;"></span>
                  <span class="lang">Shell</span>
                  <span class="percent">1.7%</span>
                </a>
            </li>
          </ol>
        </div>
      </div>
    </div>
  </div>

    <div class="repository-lang-stats-graph js-toggle-lang-stats" title="Click for language details" data-ga-click="Repository, language bar stats toggle, location:repo overview">
      <span class="language-color" aria-label="Python 98.3%" style="width:98.3%; background-color:#3572A5;" itemprop="keywords">Python</span>
      <span class="language-color" aria-label="Shell 1.7%" style="width:1.7%; background-color:#89e051;" itemprop="keywords">Shell</span>
    </div>



  <div class="file-navigation in-mid-page">

    <details class="get-repo-select-menu js-menu-container float-right position-relative dropdown-details details-reset">
  <summary class="btn btn-sm btn-primary">
    Clone or download
    <span class="dropdown-caret"></span>
  </summary>
  <div class="position-relative">
    <div class="get-repo-modal dropdown-menu dropdown-menu-sw pb-0 js-toggler-container ">
        <div class="clone-options https-clone-options">

          <h4 class="mb-1">
            Clone with HTTPS
            <a class="muted-link" href="https://help.github.com/articles/which-remote-url-should-i-use" target="_blank" title="Which remote URL should I use?">
              <svg aria-hidden="true" class="octicon octicon-question" height="16" version="1.1" viewBox="0 0 14 16" width="14"><path fill-rule="evenodd" d="M6 10h2v2H6v-2zm4-3.5C10 8.64 8 9 8 9H6c0-.55.45-1 1-1h.5c.28 0 .5-.22.5-.5v-1c0-.28-.22-.5-.5-.5h-1c-.28 0-.5.22-.5.5V7H4c0-1.5 1.5-3 3-3s3 1 3 2.5zM7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7z"></path></svg>
            </a>
          </h4>
          <p class="mb-2 get-repo-decription-text">
            Use Git or checkout with SVN using the web URL.
          </p>

          <div class="input-group js-zeroclipboard-container">
  <input type="text" class="form-control input-monospace input-sm js-zeroclipboard-target js-url-field" value="https://github.com/gaussic/text-classification-cnn-rnn.git" aria-label="Clone this repository at https://github.com/gaussic/text-classification-cnn-rnn.git" readonly="">
  <div class="input-group-button">
    <button aria-label="Copy to clipboard" class="js-zeroclipboard btn btn-sm zeroclipboard-button tooltipped tooltipped-s" data-copied-hint="Copied!" type="button"><svg aria-hidden="true" class="octicon octicon-clippy" height="16" version="1.1" viewBox="0 0 14 16" width="14"><path fill-rule="evenodd" d="M2 13h4v1H2v-1zm5-6H2v1h5V7zm2 3V8l-3 3 3 3v-2h5v-2H9zM4.5 9H2v1h2.5V9zM2 12h2.5v-1H2v1zm9 1h1v2c-.02.28-.11.52-.3.7-.19.18-.42.28-.7.3H1c-.55 0-1-.45-1-1V4c0-.55.45-1 1-1h3c0-1.11.89-2 2-2 1.11 0 2 .89 2 2h3c.55 0 1 .45 1 1v5h-1V6H1v9h10v-2zM2 5h8c0-.55-.45-1-1-1H8c-.55 0-1-.45-1-1s-.45-1-1-1-1 .45-1 1-.45 1-1 1H3c-.55 0-1 .45-1 1z"></path></svg></button>
  </div>
</div>

        </div>

      <div class="mt-2">
          <a href="https://desktop.github.com/" class="btn btn-outline get-repo-btn tooltipped tooltipped-s tooltipped-multiline" aria-label="Clone gaussic/text-classification-cnn-rnn to your computer and use it in GitHub Desktop.">
    Open in Desktop
  </a>

<a href="https://github.com/gaussic/text-classification-cnn-rnn/archive/master.zip" class="btn btn-outline get-repo-btn
" rel="nofollow" data-ga-click="Repository, download zip, location:repo overview">
  Download ZIP
</a>

      </div>
    </div>
  </div>
</details>


  <div class="BtnGroup float-right">

    <a href="https://github.com/gaussic/text-classification-cnn-rnn/find/master" class="btn btn-sm empty-icon float-right BtnGroup-item" data-pjax="" data-hotkey="t" data-ga-click="Repository, find file, location:repo overview">
      Find file
    </a>
  </div>

  
<div class="select-menu branch-select-menu js-menu-container js-select-menu float-left">
  <button class=" btn btn-sm select-menu-button js-menu-target css-truncate" data-hotkey="w" type="button" aria-label="Switch branches or tags" aria-expanded="false" aria-haspopup="true">
      <i>Branch:</i>
      <span class="js-select-button css-truncate-target">master</span>
  </button>

  <div class="select-menu-modal-holder js-menu-content js-navigation-container" data-pjax="">

    <div class="select-menu-modal">
      <div class="select-menu-header">
        <svg aria-label="Close" class="octicon octicon-x js-menu-close" height="16" role="img" version="1.1" viewBox="0 0 12 16" width="12"><path fill-rule="evenodd" d="M7.48 8l3.75 3.75-1.48 1.48L6 9.48l-3.75 3.75-1.48-1.48L4.52 8 .77 4.25l1.48-1.48L6 6.52l3.75-3.75 1.48 1.48z"></path></svg>
        <span class="select-menu-title">Switch branches/tags</span>
      </div>

      <div class="select-menu-filters">
        <div class="select-menu-text-filter">
          <input type="text" aria-label="Filter branches/tags" id="context-commitish-filter-field" class="form-control js-filterable-field js-navigation-enable" placeholder="Filter branches/tags">
        </div>
        <div class="select-menu-tabs">
          <ul>
            <li class="select-menu-tab">
              <a href="https://github.com/gaussic/text-classification-cnn-rnn#" data-tab-filter="branches" data-filter-placeholder="Filter branches/tags" class="js-select-menu-tab" role="tab">Branches</a>
            </li>
            <li class="select-menu-tab">
              <a href="https://github.com/gaussic/text-classification-cnn-rnn#" data-tab-filter="tags" data-filter-placeholder="Find a tag…" class="js-select-menu-tab" role="tab">Tags</a>
            </li>
          </ul>
        </div>
      </div>

      <div class="select-menu-list select-menu-tab-bucket js-select-menu-tab-bucket" data-tab-filter="branches" role="menu">

        <div data-filterable-for="context-commitish-filter-field" data-filterable-type="substring">


            <a class="select-menu-item js-navigation-item js-navigation-open selected" href="https://github.com/gaussic/text-classification-cnn-rnn/tree/master" data-name="master" data-skip-pjax="true" rel="nofollow">
              <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path fill-rule="evenodd" d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"></path></svg>
              <span class="select-menu-item-text css-truncate-target js-select-menu-filter-text">
                master
              </span>
            </a>
        </div>

          <div class="select-menu-no-results">Nothing to show</div>
      </div>

      <div class="select-menu-list select-menu-tab-bucket js-select-menu-tab-bucket" data-tab-filter="tags">
        <div data-filterable-for="context-commitish-filter-field" data-filterable-type="substring">


        </div>

        <div class="select-menu-no-results">Nothing to show</div>
      </div>

    </div>
  </div>
</div>


        <button type="button" class="btn btn-sm disabled tooltipped tooltipped-n new-pull-request-btn" aria-label="You must be signed in to create a pull request">
          New pull request
        </button>

  <div class="breadcrumb">
    
  </div>
</div>


  


  <div class="commit-tease js-details-container Details">
    <span class="float-right">
      Latest commit
      <a class="commit-tease-sha" href="https://github.com/gaussic/text-classification-cnn-rnn/commit/c0a7b459c9ffc1fc38bd271d16b6428e0cb16a4b" data-pjax="">
        c0a7b45
      </a>
      <span itemprop="dateModified"><relative-time datetime="2018-01-03T09:50:40Z" title="2018年1月3日 GMT+8 下午5:50">2 days ago</relative-time></span>
    </span>


      <span class="commit-author-section">
          <a href="https://github.com/gaussic" class="d-inline-block">
            <img src="./GitHub - gaussic_text-classification-cnn-rnn_ CNN-RNN中文文本分类，基于tensorflow_files/12946979" width="20" height="20" class="avatar avatar-small" alt="@gaussic">
          </a>
        
  <a href="https://github.com/gaussic" class="user-mention">gaussic</a>

      </span>

      <a href="https://github.com/gaussic/text-classification-cnn-rnn/commit/c0a7b459c9ffc1fc38bd271d16b6428e0cb16a4b" class="message" data-pjax="true" title="add predict method">add predict method</a>


  </div>



<div class="file-wrap">

  <a href="https://github.com/gaussic/text-classification-cnn-rnn/tree/c0a7b459c9ffc1fc38bd271d16b6428e0cb16a4b" class="d-none js-permalink-shortcut" data-hotkey="y">Permalink</a>

  <table class="files js-navigation-container js-active-navigation-container" data-pjax="">


    <tbody>
      <tr class="warning include-fragment-error">
        <td class="icon"><svg aria-hidden="true" class="octicon octicon-alert" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M8.865 1.52c-.18-.31-.51-.5-.87-.5s-.69.19-.87.5L.275 13.5c-.18.31-.18.69 0 1 .19.31.52.5.87.5h13.7c.36 0 .69-.19.86-.5.17-.31.18-.69.01-1L8.865 1.52zM8.995 13h-2v-2h2v2zm0-3h-2V6h2v4z"></path></svg></td>
        <td class="content" colspan="3">Failed to load latest commit information.</td>
      </tr>

        <tr class="js-navigation-item">
          <td class="icon">
            <svg aria-hidden="true" class="octicon octicon-file-directory" height="16" version="1.1" viewBox="0 0 14 16" width="14"><path fill-rule="evenodd" d="M13 4H7V3c0-.66-.31-1-1-1H1c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1h12c.55 0 1-.45 1-1V5c0-.55-.45-1-1-1zM6 4H1V3h5v1z"></path></svg>
            <img alt="" class="spinner" height="16" src="./GitHub - gaussic_text-classification-cnn-rnn_ CNN-RNN中文文本分类，基于tensorflow_files/octocat-spinner-32.gif" width="16">
          </td>
          <td class="content">
            <span class="css-truncate css-truncate-target"><a href="https://github.com/gaussic/text-classification-cnn-rnn/tree/master/data" class="js-navigation-open" id="8d777f385d3dfec8815d20f7496026dc-99256f40043282095e61a1087e02dc3189a53da7" title="data">data</a></span>
          </td>
          <td class="message">
            <span class="css-truncate css-truncate-target">
                  <a href="https://github.com/gaussic/text-classification-cnn-rnn/commit/54a15cca3bdff941c6388a89d155f84d3851319c" class="message" data-pjax="true" title="fix">fix</a>
            </span>
          </td>
          <td class="age">
            <span class="css-truncate css-truncate-target"><time-ago datetime="2017-11-03T15:52:31Z" title="2017年11月3日 GMT+8 下午11:52">2 months ago</time-ago></span>
          </td>
        </tr>
        <tr class="js-navigation-item">
          <td class="icon">
            <svg aria-hidden="true" class="octicon octicon-file-directory" height="16" version="1.1" viewBox="0 0 14 16" width="14"><path fill-rule="evenodd" d="M13 4H7V3c0-.66-.31-1-1-1H1c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1h12c.55 0 1-.45 1-1V5c0-.55-.45-1-1-1zM6 4H1V3h5v1z"></path></svg>
            <img alt="" class="spinner" height="16" src="./GitHub - gaussic_text-classification-cnn-rnn_ CNN-RNN中文文本分类，基于tensorflow_files/octocat-spinner-32.gif" width="16">
          </td>
          <td class="content">
            <span class="css-truncate css-truncate-target"><a href="https://github.com/gaussic/text-classification-cnn-rnn/tree/master/helper" class="js-navigation-open" id="fde5d67bfb6dc4b598291cc2ce35ee4a-e0b7c755ad5a25e60062f6991279cfdb054eb714" title="helper">helper</a></span>
          </td>
          <td class="message">
            <span class="css-truncate css-truncate-target">
                  <a href="https://github.com/gaussic/text-classification-cnn-rnn/commit/331958a1e0e1911aaa574a5c20d22e5636c3de0a" class="message" data-pjax="true" title="fixed import">fixed import</a>
            </span>
          </td>
          <td class="age">
            <span class="css-truncate css-truncate-target"><time-ago datetime="2017-08-31T08:33:28Z" title="2017年8月31日 GMT+8 下午4:33">4 months ago</time-ago></span>
          </td>
        </tr>
        <tr class="js-navigation-item">
          <td class="icon">
            <svg aria-hidden="true" class="octicon octicon-file-directory" height="16" version="1.1" viewBox="0 0 14 16" width="14"><path fill-rule="evenodd" d="M13 4H7V3c0-.66-.31-1-1-1H1c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1h12c.55 0 1-.45 1-1V5c0-.55-.45-1-1-1zM6 4H1V3h5v1z"></path></svg>
            <img alt="" class="spinner" height="16" src="./GitHub - gaussic_text-classification-cnn-rnn_ CNN-RNN中文文本分类，基于tensorflow_files/octocat-spinner-32.gif" width="16">
          </td>
          <td class="content">
            <span class="css-truncate css-truncate-target"><a href="https://github.com/gaussic/text-classification-cnn-rnn/tree/master/images" class="js-navigation-open" id="59b514174bffe4ae402b3d63aad79fe0-2a929a0312387a8d39f3fa5fe759af5100fb99d6" title="images">images</a></span>
          </td>
          <td class="message">
            <span class="css-truncate css-truncate-target">
                  <a href="https://github.com/gaussic/text-classification-cnn-rnn/commit/a8b541a447fae0b1853b6fce143a766fd6ba6840" class="message" data-pjax="true" title="update README.md">update README.md</a>
            </span>
          </td>
          <td class="age">
            <span class="css-truncate css-truncate-target"><time-ago datetime="2017-10-20T08:03:20Z" title="2017年10月20日 GMT+8 下午4:03">3 months ago</time-ago></span>
          </td>
        </tr>
        <tr class="js-navigation-item">
          <td class="icon">
            <svg aria-hidden="true" class="octicon octicon-file-text" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M6 5H2V4h4v1zM2 8h7V7H2v1zm0 2h7V9H2v1zm0 2h7v-1H2v1zm10-7.5V14c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1V2c0-.55.45-1 1-1h7.5L12 4.5zM11 5L8 2H1v12h10V5z"></path></svg>
            <img alt="" class="spinner" height="16" src="./GitHub - gaussic_text-classification-cnn-rnn_ CNN-RNN中文文本分类，基于tensorflow_files/octocat-spinner-32.gif" width="16">
          </td>
          <td class="content">
            <span class="css-truncate css-truncate-target"><a href="https://github.com/gaussic/text-classification-cnn-rnn/blob/master/.gitignore" class="js-navigation-open" id="a084b794bc0759e7a6b77810e01874f2-29537bb873f1829e7203a298aa060e04ad9a20a8" title=".gitignore">.gitignore</a></span>
          </td>
          <td class="message">
            <span class="css-truncate css-truncate-target">
                  <a href="https://github.com/gaussic/text-classification-cnn-rnn/commit/a8b541a447fae0b1853b6fce143a766fd6ba6840" class="message" data-pjax="true" title="update README.md">update README.md</a>
            </span>
          </td>
          <td class="age">
            <span class="css-truncate css-truncate-target"><time-ago datetime="2017-10-20T08:03:20Z" title="2017年10月20日 GMT+8 下午4:03">3 months ago</time-ago></span>
          </td>
        </tr>
        <tr class="js-navigation-item">
          <td class="icon">
            <svg aria-hidden="true" class="octicon octicon-file-text" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M6 5H2V4h4v1zM2 8h7V7H2v1zm0 2h7V9H2v1zm0 2h7v-1H2v1zm10-7.5V14c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1V2c0-.55.45-1 1-1h7.5L12 4.5zM11 5L8 2H1v12h10V5z"></path></svg>
            <img alt="" class="spinner" height="16" src="./GitHub - gaussic_text-classification-cnn-rnn_ CNN-RNN中文文本分类，基于tensorflow_files/octocat-spinner-32.gif" width="16">
          </td>
          <td class="content">
            <span class="css-truncate css-truncate-target"><a href="https://github.com/gaussic/text-classification-cnn-rnn/blob/master/LICENSE" class="js-navigation-open" id="9879d6db96fd29134fc802214163b95a-24a0aa5bfec0696c673cc6a41b0ee15770c29426" itemprop="license" title="LICENSE">LICENSE</a></span>
          </td>
          <td class="message">
            <span class="css-truncate css-truncate-target">
                  <a href="https://github.com/gaussic/text-classification-cnn-rnn/commit/5f2677f2ce21441a739369695882cb2c65550b61" class="message" data-pjax="true" title="Initial commit">Initial commit</a>
            </span>
          </td>
          <td class="age">
            <span class="css-truncate css-truncate-target"><time-ago datetime="2017-08-28T05:41:22Z" title="2017年8月28日 GMT+8 下午1:41">4 months ago</time-ago></span>
          </td>
        </tr>
        <tr class="js-navigation-item">
          <td class="icon">
            <svg aria-hidden="true" class="octicon octicon-file-text" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M6 5H2V4h4v1zM2 8h7V7H2v1zm0 2h7V9H2v1zm0 2h7v-1H2v1zm10-7.5V14c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1V2c0-.55.45-1 1-1h7.5L12 4.5zM11 5L8 2H1v12h10V5z"></path></svg>
            <img alt="" class="spinner" height="16" src="./GitHub - gaussic_text-classification-cnn-rnn_ CNN-RNN中文文本分类，基于tensorflow_files/octocat-spinner-32.gif" width="16">
          </td>
          <td class="content">
            <span class="css-truncate css-truncate-target"><a href="https://github.com/gaussic/text-classification-cnn-rnn/blob/master/README.md" class="js-navigation-open" id="04c6e90faac2675aa89e2176d2eec7d8-61a86c472b923e06a6b665e97030ace62ea74196" title="README.md">README.md</a></span>
          </td>
          <td class="message">
            <span class="css-truncate css-truncate-target">
                  <a href="https://github.com/gaussic/text-classification-cnn-rnn/commit/22b236d7c6f8c48712fa00239099e86dab8520cf" class="message" data-pjax="true" title="update README.md">update README.md</a>
            </span>
          </td>
          <td class="age">
            <span class="css-truncate css-truncate-target"><time-ago datetime="2017-11-01T05:21:21Z" title="2017年11月1日 GMT+8 下午1:21">2 months ago</time-ago></span>
          </td>
        </tr>
        <tr class="js-navigation-item">
          <td class="icon">
            <svg aria-hidden="true" class="octicon octicon-file-text" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M6 5H2V4h4v1zM2 8h7V7H2v1zm0 2h7V9H2v1zm0 2h7v-1H2v1zm10-7.5V14c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1V2c0-.55.45-1 1-1h7.5L12 4.5zM11 5L8 2H1v12h10V5z"></path></svg>
            <img alt="" class="spinner" height="16" src="./GitHub - gaussic_text-classification-cnn-rnn_ CNN-RNN中文文本分类，基于tensorflow_files/octocat-spinner-32.gif" width="16">
          </td>
          <td class="content">
            <span class="css-truncate css-truncate-target"><a href="https://github.com/gaussic/text-classification-cnn-rnn/blob/master/cnn_model.py" class="js-navigation-open" id="61ddc1b161e31e8ce48079c87ff9624c-bf2813374a3194fa177a440edfc551eac103948e" title="cnn_model.py">cnn_model.py</a></span>
          </td>
          <td class="message">
            <span class="css-truncate css-truncate-target">
                  <a href="https://github.com/gaussic/text-classification-cnn-rnn/commit/b051b58cd25fc937d97f00d0d168ad54da99669f" class="message" data-pjax="true" title="cnn train and test">cnn train and test</a>
            </span>
          </td>
          <td class="age">
            <span class="css-truncate css-truncate-target"><time-ago datetime="2017-10-20T06:03:01Z" title="2017年10月20日 GMT+8 下午2:03">3 months ago</time-ago></span>
          </td>
        </tr>
        <tr class="js-navigation-item navigation-focus">
          <td class="icon">
            <svg aria-hidden="true" class="octicon octicon-file-text" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M6 5H2V4h4v1zM2 8h7V7H2v1zm0 2h7V9H2v1zm0 2h7v-1H2v1zm10-7.5V14c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1V2c0-.55.45-1 1-1h7.5L12 4.5zM11 5L8 2H1v12h10V5z"></path></svg>
            <img alt="" class="spinner" height="16" src="./GitHub - gaussic_text-classification-cnn-rnn_ CNN-RNN中文文本分类，基于tensorflow_files/octocat-spinner-32.gif" width="16">
          </td>
          <td class="content">
            <span class="css-truncate css-truncate-target"><a href="https://github.com/gaussic/text-classification-cnn-rnn/blob/master/predict.py" class="js-navigation-open" id="edbc9656fed5d96f9b65fe784439851d-35c1e838a960bb732a6920f37fbffc56d12870f6" title="predict.py">predict.py</a></span>
          </td>
          <td class="message">
            <span class="css-truncate css-truncate-target">
                  <a href="https://github.com/gaussic/text-classification-cnn-rnn/commit/c0a7b459c9ffc1fc38bd271d16b6428e0cb16a4b" class="message" data-pjax="true" title="add predict method">add predict method</a>
            </span>
          </td>
          <td class="age">
            <span class="css-truncate css-truncate-target"><time-ago datetime="2018-01-03T09:50:40Z" title="2018年1月3日 GMT+8 下午5:50">2 days ago</time-ago></span>
          </td>
        </tr>
        <tr class="js-navigation-item">
          <td class="icon">
            <svg aria-hidden="true" class="octicon octicon-file-text" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M6 5H2V4h4v1zM2 8h7V7H2v1zm0 2h7V9H2v1zm0 2h7v-1H2v1zm10-7.5V14c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1V2c0-.55.45-1 1-1h7.5L12 4.5zM11 5L8 2H1v12h10V5z"></path></svg>
            <img alt="" class="spinner" height="16" src="./GitHub - gaussic_text-classification-cnn-rnn_ CNN-RNN中文文本分类，基于tensorflow_files/octocat-spinner-32.gif" width="16">
          </td>
          <td class="content">
            <span class="css-truncate css-truncate-target"><a href="https://github.com/gaussic/text-classification-cnn-rnn/blob/master/rnn_model.py" class="js-navigation-open" id="fc8b28474b12e9e42aeaaa2abb81b3c6-c21cf0c2fade858b7089957e8effadc687155fbc" title="rnn_model.py">rnn_model.py</a></span>
          </td>
          <td class="message">
            <span class="css-truncate css-truncate-target">
                  <a href="https://github.com/gaussic/text-classification-cnn-rnn/commit/6ab30f0418978d471ff13c1c23112c8b3c3e6f9f" class="message" data-pjax="true" title="rnn model">rnn model</a>
            </span>
          </td>
          <td class="age">
            <span class="css-truncate css-truncate-target"><time-ago datetime="2017-10-20T07:57:26Z" title="2017年10月20日 GMT+8 下午3:57">3 months ago</time-ago></span>
          </td>
        </tr>
        <tr class="js-navigation-item">
          <td class="icon">
            <svg aria-hidden="true" class="octicon octicon-file-text" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M6 5H2V4h4v1zM2 8h7V7H2v1zm0 2h7V9H2v1zm0 2h7v-1H2v1zm10-7.5V14c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1V2c0-.55.45-1 1-1h7.5L12 4.5zM11 5L8 2H1v12h10V5z"></path></svg>
            <img alt="" class="spinner" height="16" src="./GitHub - gaussic_text-classification-cnn-rnn_ CNN-RNN中文文本分类，基于tensorflow_files/octocat-spinner-32.gif" width="16">
          </td>
          <td class="content">
            <span class="css-truncate css-truncate-target"><a href="https://github.com/gaussic/text-classification-cnn-rnn/blob/master/run_cnn.py" class="js-navigation-open" id="e36635e98f373ec7d2603c1538470ba0-417b8d8859de5accbb847029d8760f67ed136c10" title="run_cnn.py">run_cnn.py</a></span>
          </td>
          <td class="message">
            <span class="css-truncate css-truncate-target">
                  <a href="https://github.com/gaussic/text-classification-cnn-rnn/commit/7aa242f2d9b7d616379f22758348a106ca98d139" class="message" data-pjax="true" title="fix vocab configuration">fix vocab configuration</a>
            </span>
          </td>
          <td class="age">
            <span class="css-truncate css-truncate-target"><time-ago datetime="2017-11-01T05:11:13Z" title="2017年11月1日 GMT+8 下午1:11">2 months ago</time-ago></span>
          </td>
        </tr>
        <tr class="js-navigation-item">
          <td class="icon">
            <svg aria-hidden="true" class="octicon octicon-file-text" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path d="M6 5H2V4h4v1zM2 8h7V7H2v1zm0 2h7V9H2v1zm0 2h7v-1H2v1zm10-7.5V14c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1V2c0-.55.45-1 1-1h7.5L12 4.5zM11 5L8 2H1v12h10V5z"></path></svg>
            <img alt="" class="spinner" height="16" src="./GitHub - gaussic_text-classification-cnn-rnn_ CNN-RNN中文文本分类，基于tensorflow_files/octocat-spinner-32.gif" width="16">
          </td>
          <td class="content">
            <span class="css-truncate css-truncate-target"><a href="https://github.com/gaussic/text-classification-cnn-rnn/blob/master/run_rnn.py" class="js-navigation-open" id="98782a0be0a4b3a83d281dd1807d92d6-7ecdd6705f98931852ab9a75eb0fa823e292737f" title="run_rnn.py">run_rnn.py</a></span>
          </td>
          <td class="message">
            <span class="css-truncate css-truncate-target">
                  <a href="https://github.com/gaussic/text-classification-cnn-rnn/commit/7aa242f2d9b7d616379f22758348a106ca98d139" class="message" data-pjax="true" title="fix vocab configuration">fix vocab configuration</a>
            </span>
          </td>
          <td class="age">
            <span class="css-truncate css-truncate-target"><time-ago datetime="2017-11-01T05:11:13Z" title="2017年11月1日 GMT+8 下午1:11">2 months ago</time-ago></span>
          </td>
        </tr>
    </tbody>
  </table>

</div>



  <div id="readme" class="readme boxed-group clearfix announce instapaper_body md">
    <h3>
      <svg aria-hidden="true" class="octicon octicon-book" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M3 5h4v1H3V5zm0 3h4V7H3v1zm0 2h4V9H3v1zm11-5h-4v1h4V5zm0 2h-4v1h4V7zm0 2h-4v1h4V9zm2-6v9c0 .55-.45 1-1 1H9.5l-1 1-1-1H2c-.55 0-1-.45-1-1V3c0-.55.45-1 1-1h5.5l1 1 1-1H15c.55 0 1 .45 1 1zm-8 .5L7.5 3H2v9h6V3.5zm7-.5H9.5l-.5.5V12h6V3z"></path></svg>
      README.md
    </h3>

      <article class="markdown-body entry-content" itemprop="text"><h1><a href="https://github.com/gaussic/text-classification-cnn-rnn#text-classification-with-cnn-and-rnn" aria-hidden="true" class="anchor" id="user-content-text-classification-with-cnn-and-rnn"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Text Classification with CNN and RNN</h1>
<p>使用卷积神经网络以及循环神经网络进行中文文本分类</p>
<p>CNN做句子分类的论文可以参看: <a href="https://arxiv.org/abs/1408.5882">Convolutional Neural Networks for Sentence Classification</a></p>
<p>还可以去读dennybritz大牛的博客：<a href="http://www.wildml.com/2015/12/implementing-a-cnn-for-text-classification-in-tensorflow/">Implementing a CNN for Text Classification in TensorFlow</a></p>
<p>以及字符级CNN的论文：<a href="https://arxiv.org/abs/1509.01626">Character-level Convolutional Networks for Text Classification</a></p>
<p>本文是基于TensorFlow在中文数据集上的简化实现，使用了字符级CNN和RNN对中文文本进行分类，达到了较好的效果。</p>
<h2><a href="https://github.com/gaussic/text-classification-cnn-rnn#环境" aria-hidden="true" class="anchor" id="user-content-环境"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>环境</h2>
<ul>
<li>Python 3.5</li>
<li>TensorFlow 1.3</li>
<li>numpy</li>
<li>scikit-learn</li>
</ul>
<h2><a href="https://github.com/gaussic/text-classification-cnn-rnn#数据集" aria-hidden="true" class="anchor" id="user-content-数据集"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>数据集</h2>
<p>使用THUCNews的一个子集进行训练与测试，数据集请自行到<a href="http://thuctc.thunlp.org/">THUCTC：一个高效的中文文本分类工具包</a>下载，请遵循数据提供方的开源协议。</p>
<p>本次训练使用了其中的10个分类，每个分类6500条数据。</p>
<p>类别如下：</p>
<pre><code>体育, 财经, 房产, 家居, 教育, 科技, 时尚, 时政, 游戏, 娱乐
</code></pre>
<p>这个子集可以在此下载：链接:<a href="http://pan.baidu.com/s/1bpq9Eub">http://pan.baidu.com/s/1bpq9Eub</a>  密码:ycyw</p>
<p>数据集划分如下：</p>
<ul>
<li>训练集: 5000*10</li>
<li>验证集: 500*10</li>
<li>测试集: 1000*10</li>
</ul>
<p>从原数据集生成子集的过程请参看<code>helper</code>下的两个脚本。其中，<code>copy_data.sh</code>用于从每个分类拷贝6500个文件，<code>cnews_group.py</code>用于将多个文件整合到一个文件中。执行该文件后，得到三个数据文件：</p>
<ul>
<li>cnews.train.txt: 训练集(50000条)</li>
<li>cnews.val.txt: 验证集(5000条)</li>
<li>cnews.test.txt: 测试集(10000条)</li>
</ul>
<h2><a href="https://github.com/gaussic/text-classification-cnn-rnn#预处理" aria-hidden="true" class="anchor" id="user-content-预处理"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>预处理</h2>
<p><code>data/cnews_loader.py</code>为数据的预处理文件。</p>
<ul>
<li><code>read_file()</code>: 读取文件数据;</li>
<li><code>build_vocab()</code>: 构建词汇表，使用字符级的表示，这一函数会将词汇表存储下来，避免每一次重复处理;</li>
<li><code>read_vocab()</code>: 读取上一步存储的词汇表，转换为<code>{词：id}</code>表示;</li>
<li><code>read_category()</code>: 将分类目录固定，转换为<code>{类别: id}</code>表示;</li>
<li><code>to_words()</code>: 将一条由id表示的数据重新转换为文字;</li>
<li><code>preocess_file()</code>: 将数据集从文字转换为固定长度的id序列表示;</li>
<li><code>batch_iter()</code>: 为神经网络的训练准备经过shuffle的批次的数据。</li>
</ul>
<p>经过数据预处理，数据的格式如下：</p>
<table>
<thead>
<tr>
<th align="left">Data</th>
<th align="left">Shape</th>
<th align="left">Data</th>
<th align="left">Shape</th>
</tr>
</thead>
<tbody>
<tr>
<td align="left">x_train</td>
<td align="left">[50000, 600]</td>
<td align="left">y_train</td>
<td align="left">[50000, 10]</td>
</tr>
<tr>
<td align="left">x_val</td>
<td align="left">[5000, 600]</td>
<td align="left">y_val</td>
<td align="left">[5000, 10]</td>
</tr>
<tr>
<td align="left">x_test</td>
<td align="left">[10000, 600]</td>
<td align="left">y_test</td>
<td align="left">[10000, 10]</td>
</tr></tbody></table>
<h2><a href="https://github.com/gaussic/text-classification-cnn-rnn#cnn卷积神经网络" aria-hidden="true" class="anchor" id="user-content-cnn卷积神经网络"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>CNN卷积神经网络</h2>
<h3><a href="https://github.com/gaussic/text-classification-cnn-rnn#配置项" aria-hidden="true" class="anchor" id="user-content-配置项"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>配置项</h3>
<p>CNN可配置的参数如下所示，在<code>cnn_model.py</code>中。</p>
<div class="highlight highlight-source-python"><pre><span class="pl-k">class</span> <span class="pl-en">TCNNConfig</span>(<span class="pl-c1">object</span>):
    <span class="pl-s"><span class="pl-pds">"""</span>CNN配置参数<span class="pl-pds">"""</span></span>

    embedding_dim <span class="pl-k">=</span> <span class="pl-c1">64</span>      <span class="pl-c"><span class="pl-c">#</span> 词向量维度</span>
    seq_length <span class="pl-k">=</span> <span class="pl-c1">600</span>        <span class="pl-c"><span class="pl-c">#</span> 序列长度</span>
    num_classes <span class="pl-k">=</span> <span class="pl-c1">10</span>        <span class="pl-c"><span class="pl-c">#</span> 类别数</span>
    num_filters <span class="pl-k">=</span> <span class="pl-c1">128</span>        <span class="pl-c"><span class="pl-c">#</span> 卷积核数目</span>
    kernel_size <span class="pl-k">=</span> <span class="pl-c1">5</span>         <span class="pl-c"><span class="pl-c">#</span> 卷积核尺寸</span>
    vocab_size <span class="pl-k">=</span> <span class="pl-c1">5000</span>       <span class="pl-c"><span class="pl-c">#</span> 词汇表达小</span>

    hidden_dim <span class="pl-k">=</span> <span class="pl-c1">128</span>        <span class="pl-c"><span class="pl-c">#</span> 全连接层神经元</span>

    dropout_keep_prob <span class="pl-k">=</span> <span class="pl-c1">0.5</span> <span class="pl-c"><span class="pl-c">#</span> dropout保留比例</span>
    learning_rate <span class="pl-k">=</span> <span class="pl-c1">1e-3</span>    <span class="pl-c"><span class="pl-c">#</span> 学习率</span>

    batch_size <span class="pl-k">=</span> <span class="pl-c1">64</span>         <span class="pl-c"><span class="pl-c">#</span> 每批训练大小</span>
    num_epochs <span class="pl-k">=</span> <span class="pl-c1">10</span>         <span class="pl-c"><span class="pl-c">#</span> 总迭代轮次</span>

    print_per_batch <span class="pl-k">=</span> <span class="pl-c1">100</span>    <span class="pl-c"><span class="pl-c">#</span> 每多少轮输出一次结果</span>
    save_per_batch <span class="pl-k">=</span> <span class="pl-c1">10</span>      <span class="pl-c"><span class="pl-c">#</span> 每多少轮存入tensorboard</span></pre></div>
<h3><a href="https://github.com/gaussic/text-classification-cnn-rnn#cnn模型" aria-hidden="true" class="anchor" id="user-content-cnn模型"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>CNN模型</h3>
<p>具体参看<code>cnn_model.py</code>的实现。</p>
<p>大致结构如下：</p>
<p><a href="https://github.com/gaussic/text-classification-cnn-rnn/blob/master/images/cnn_architecture.png" target="_blank"><img src="./GitHub - gaussic_text-classification-cnn-rnn_ CNN-RNN中文文本分类，基于tensorflow_files/cnn_architecture.png" alt="images/cnn_architecture" style="max-width:100%;"></a></p>
<h3><a href="https://github.com/gaussic/text-classification-cnn-rnn#训练与验证" aria-hidden="true" class="anchor" id="user-content-训练与验证"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>训练与验证</h3>
<p>运行 <code>python run_cnn.py train</code>，可以开始训练。</p>
<blockquote>
<p>若之前进行过训练，请把tensorboard/textcnn删除，避免TensorBoard多次训练结果重叠。</p>
</blockquote>
<pre><code>Configuring CNN model...
Configuring TensorBoard and Saver...
Loading training and validation data...
Time usage: 0:00:14
Training and evaluating...
Epoch: 1
Iter:      0, Train Loss:    2.3, Train Acc:  10.94%, Val Loss:    2.3, Val Acc:   8.92%, Time: 0:00:01 *
Iter:    100, Train Loss:   0.88, Train Acc:  73.44%, Val Loss:    1.2, Val Acc:  68.46%, Time: 0:00:04 *
Iter:    200, Train Loss:   0.38, Train Acc:  92.19%, Val Loss:   0.75, Val Acc:  77.32%, Time: 0:00:07 *
Iter:    300, Train Loss:   0.22, Train Acc:  92.19%, Val Loss:   0.46, Val Acc:  87.08%, Time: 0:00:09 *
Iter:    400, Train Loss:   0.24, Train Acc:  90.62%, Val Loss:    0.4, Val Acc:  88.62%, Time: 0:00:12 *
Iter:    500, Train Loss:   0.16, Train Acc:  96.88%, Val Loss:   0.36, Val Acc:  90.38%, Time: 0:00:15 *
Iter:    600, Train Loss:  0.084, Train Acc:  96.88%, Val Loss:   0.35, Val Acc:  91.36%, Time: 0:00:17 *
Iter:    700, Train Loss:   0.21, Train Acc:  93.75%, Val Loss:   0.26, Val Acc:  92.58%, Time: 0:00:20 *
Epoch: 2
Iter:    800, Train Loss:   0.07, Train Acc:  98.44%, Val Loss:   0.24, Val Acc:  94.12%, Time: 0:00:23 *
Iter:    900, Train Loss:  0.092, Train Acc:  96.88%, Val Loss:   0.27, Val Acc:  92.86%, Time: 0:00:25
Iter:   1000, Train Loss:   0.17, Train Acc:  95.31%, Val Loss:   0.28, Val Acc:  92.82%, Time: 0:00:28
Iter:   1100, Train Loss:    0.2, Train Acc:  93.75%, Val Loss:   0.23, Val Acc:  93.26%, Time: 0:00:31
Iter:   1200, Train Loss:  0.081, Train Acc:  98.44%, Val Loss:   0.25, Val Acc:  92.96%, Time: 0:00:33
Iter:   1300, Train Loss:  0.052, Train Acc: 100.00%, Val Loss:   0.24, Val Acc:  93.58%, Time: 0:00:36
Iter:   1400, Train Loss:    0.1, Train Acc:  95.31%, Val Loss:   0.22, Val Acc:  94.12%, Time: 0:00:39
Iter:   1500, Train Loss:   0.12, Train Acc:  98.44%, Val Loss:   0.23, Val Acc:  93.58%, Time: 0:00:41
Epoch: 3
Iter:   1600, Train Loss:    0.1, Train Acc:  96.88%, Val Loss:   0.26, Val Acc:  92.34%, Time: 0:00:44
Iter:   1700, Train Loss:  0.018, Train Acc: 100.00%, Val Loss:   0.22, Val Acc:  93.46%, Time: 0:00:47
Iter:   1800, Train Loss:  0.036, Train Acc: 100.00%, Val Loss:   0.28, Val Acc:  92.72%, Time: 0:00:50
No optimization for a long time, auto-stopping...
</code></pre>
<p>在验证集上的最佳效果为94.12%，且只经过了3轮迭代就已经停止。</p>
<p>准确率和误差如图所示：</p>
<p><a href="https://github.com/gaussic/text-classification-cnn-rnn/blob/master/images/acc_loss.png" target="_blank"><img src="./GitHub - gaussic_text-classification-cnn-rnn_ CNN-RNN中文文本分类，基于tensorflow_files/acc_loss.png" alt="images" style="max-width:100%;"></a></p>
<h3><a href="https://github.com/gaussic/text-classification-cnn-rnn#测试" aria-hidden="true" class="anchor" id="user-content-测试"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>测试</h3>
<p>运行 <code>python run_cnn.py test</code> 在测试集上进行测试。</p>
<pre><code>Configuring CNN model...
Loading test data...
Testing...
Test Loss:   0.14, Test Acc:  96.04%
Precision, Recall and F1-Score...
             precision    recall  f1-score   support

         体育       0.99      0.99      0.99      1000
         财经       0.96      0.99      0.97      1000
         房产       1.00      1.00      1.00      1000
         家居       0.95      0.91      0.93      1000
         教育       0.95      0.89      0.92      1000
         科技       0.94      0.97      0.95      1000
         时尚       0.95      0.97      0.96      1000
         时政       0.94      0.94      0.94      1000
         游戏       0.97      0.96      0.97      1000
         娱乐       0.95      0.98      0.97      1000

avg / total       0.96      0.96      0.96     10000

Confusion Matrix...
[[991   0   0   0   2   1   0   4   1   1]
 [  0 992   0   0   2   1   0   5   0   0]
 [  0   1 996   0   1   1   0   0   0   1]
 [  0  14   0 912   7  15   9  29   3  11]
 [  2   9   0  12 892  22  18  21  10  14]
 [  0   0   0  10   1 968   4   3  12   2]
 [  1   0   0   9   4   4 971   0   2   9]
 [  1  16   0   4  18  12   1 941   1   6]
 [  2   4   1   5   4   5  10   1 962   6]
 [  1   0   1   6   4   3   5   0   1 979]]
Time usage: 0:00:05
</code></pre>
<p>在测试集上的准确率达到了96.04%，且各类的precision, recall和f1-score都超过了0.9。</p>
<p>从混淆矩阵也可以看出分类效果非常优秀。</p>
<h2><a href="https://github.com/gaussic/text-classification-cnn-rnn#rnn循环神经网络" aria-hidden="true" class="anchor" id="user-content-rnn循环神经网络"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>RNN循环神经网络</h2>
<h3><a href="https://github.com/gaussic/text-classification-cnn-rnn#配置项-1" aria-hidden="true" class="anchor" id="user-content-配置项-1"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>配置项</h3>
<p>RNN可配置的参数如下所示，在<code>rnn_model.py</code>中。</p>
<div class="highlight highlight-source-python"><pre><span class="pl-k">class</span> <span class="pl-en">TRNNConfig</span>(<span class="pl-c1">object</span>):
    <span class="pl-s"><span class="pl-pds">"""</span>RNN配置参数<span class="pl-pds">"""</span></span>

    <span class="pl-c"><span class="pl-c">#</span> 模型参数</span>
    embedding_dim <span class="pl-k">=</span> <span class="pl-c1">64</span>      <span class="pl-c"><span class="pl-c">#</span> 词向量维度</span>
    seq_length <span class="pl-k">=</span> <span class="pl-c1">600</span>        <span class="pl-c"><span class="pl-c">#</span> 序列长度</span>
    num_classes <span class="pl-k">=</span> <span class="pl-c1">10</span>        <span class="pl-c"><span class="pl-c">#</span> 类别数</span>
    vocab_size <span class="pl-k">=</span> <span class="pl-c1">5000</span>       <span class="pl-c"><span class="pl-c">#</span> 词汇表达小</span>

    num_layers<span class="pl-k">=</span> <span class="pl-c1">2</span>           <span class="pl-c"><span class="pl-c">#</span> 隐藏层层数</span>
    hidden_dim <span class="pl-k">=</span> <span class="pl-c1">128</span>        <span class="pl-c"><span class="pl-c">#</span> 隐藏层神经元</span>
    rnn <span class="pl-k">=</span> <span class="pl-s"><span class="pl-pds">'</span>gru<span class="pl-pds">'</span></span>             <span class="pl-c"><span class="pl-c">#</span> lstm 或 gru</span>

    dropout_keep_prob <span class="pl-k">=</span> <span class="pl-c1">0.8</span> <span class="pl-c"><span class="pl-c">#</span> dropout保留比例</span>
    learning_rate <span class="pl-k">=</span> <span class="pl-c1">1e-3</span>    <span class="pl-c"><span class="pl-c">#</span> 学习率</span>

    batch_size <span class="pl-k">=</span> <span class="pl-c1">128</span>         <span class="pl-c"><span class="pl-c">#</span> 每批训练大小</span>
    num_epochs <span class="pl-k">=</span> <span class="pl-c1">10</span>          <span class="pl-c"><span class="pl-c">#</span> 总迭代轮次</span>

    print_per_batch <span class="pl-k">=</span> <span class="pl-c1">100</span>    <span class="pl-c"><span class="pl-c">#</span> 每多少轮输出一次结果</span>
    save_per_batch <span class="pl-k">=</span> <span class="pl-c1">10</span>      <span class="pl-c"><span class="pl-c">#</span> 每多少轮存入tensorboard</span></pre></div>
<h3><a href="https://github.com/gaussic/text-classification-cnn-rnn#rnn模型" aria-hidden="true" class="anchor" id="user-content-rnn模型"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>RNN模型</h3>
<p>具体参看<code>rnn_model.py</code>的实现。</p>
<p>大致结构如下：</p>
<p><a href="https://github.com/gaussic/text-classification-cnn-rnn/blob/master/images/rnn_architecture.png" target="_blank"><img src="./GitHub - gaussic_text-classification-cnn-rnn_ CNN-RNN中文文本分类，基于tensorflow_files/rnn_architecture.png" alt="images/rnn_architecture" style="max-width:100%;"></a></p>
<h3><a href="https://github.com/gaussic/text-classification-cnn-rnn#训练与验证-1" aria-hidden="true" class="anchor" id="user-content-训练与验证-1"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>训练与验证</h3>
<blockquote>
<p>这部分的代码与 run_cnn.py极为相似，只需要将模型和部分目录稍微修改。</p>
</blockquote>
<p>运行 <code>python run_rnn.py train</code>，可以开始训练。</p>
<blockquote>
<p>若之前进行过训练，请把tensorboard/textrnn删除，避免TensorBoard多次训练结果重叠。</p>
</blockquote>
<pre><code>Configuring RNN model...
Configuring TensorBoard and Saver...
Loading training and validation data...
Time usage: 0:00:14
Training and evaluating...
Epoch: 1
Iter:      0, Train Loss:    2.3, Train Acc:   8.59%, Val Loss:    2.3, Val Acc:  11.96%, Time: 0:00:08 *
Iter:    100, Train Loss:   0.95, Train Acc:  64.06%, Val Loss:    1.3, Val Acc:  53.06%, Time: 0:01:15 *
Iter:    200, Train Loss:   0.61, Train Acc:  79.69%, Val Loss:   0.94, Val Acc:  69.88%, Time: 0:02:22 *
Iter:    300, Train Loss:   0.49, Train Acc:  85.16%, Val Loss:   0.63, Val Acc:  81.44%, Time: 0:03:29 *
Epoch: 2
Iter:    400, Train Loss:   0.23, Train Acc:  92.97%, Val Loss:    0.6, Val Acc:  82.86%, Time: 0:04:36 *
Iter:    500, Train Loss:   0.27, Train Acc:  92.97%, Val Loss:   0.47, Val Acc:  86.72%, Time: 0:05:43 *
Iter:    600, Train Loss:   0.13, Train Acc:  98.44%, Val Loss:   0.43, Val Acc:  87.46%, Time: 0:06:50 *
Iter:    700, Train Loss:   0.24, Train Acc:  91.41%, Val Loss:   0.46, Val Acc:  87.12%, Time: 0:07:57
Epoch: 3
Iter:    800, Train Loss:   0.11, Train Acc:  96.09%, Val Loss:   0.49, Val Acc:  87.02%, Time: 0:09:03
Iter:    900, Train Loss:   0.15, Train Acc:  96.09%, Val Loss:   0.55, Val Acc:  85.86%, Time: 0:10:10
Iter:   1000, Train Loss:   0.17, Train Acc:  96.09%, Val Loss:   0.43, Val Acc:  89.44%, Time: 0:11:18 *
Iter:   1100, Train Loss:   0.25, Train Acc:  93.75%, Val Loss:   0.42, Val Acc:  88.98%, Time: 0:12:25
Epoch: 4
Iter:   1200, Train Loss:   0.14, Train Acc:  96.09%, Val Loss:   0.39, Val Acc:  89.82%, Time: 0:13:32 *
Iter:   1300, Train Loss:    0.2, Train Acc:  96.09%, Val Loss:   0.43, Val Acc:  88.68%, Time: 0:14:38
Iter:   1400, Train Loss:  0.012, Train Acc: 100.00%, Val Loss:   0.37, Val Acc:  90.58%, Time: 0:15:45 *
Iter:   1500, Train Loss:   0.15, Train Acc:  96.88%, Val Loss:   0.39, Val Acc:  90.58%, Time: 0:16:52
Epoch: 5
Iter:   1600, Train Loss:  0.075, Train Acc:  97.66%, Val Loss:   0.41, Val Acc:  89.90%, Time: 0:17:59
Iter:   1700, Train Loss:  0.042, Train Acc:  98.44%, Val Loss:   0.41, Val Acc:  90.08%, Time: 0:19:06
Iter:   1800, Train Loss:   0.08, Train Acc:  97.66%, Val Loss:   0.38, Val Acc:  91.36%, Time: 0:20:13 *
Iter:   1900, Train Loss:  0.089, Train Acc:  98.44%, Val Loss:   0.39, Val Acc:  90.18%, Time: 0:21:20
Epoch: 6
Iter:   2000, Train Loss:  0.092, Train Acc:  96.88%, Val Loss:   0.36, Val Acc:  91.42%, Time: 0:22:27 *
Iter:   2100, Train Loss:  0.062, Train Acc:  98.44%, Val Loss:   0.39, Val Acc:  90.56%, Time: 0:23:34
Iter:   2200, Train Loss:  0.053, Train Acc:  98.44%, Val Loss:   0.39, Val Acc:  90.02%, Time: 0:24:41
Iter:   2300, Train Loss:   0.12, Train Acc:  96.09%, Val Loss:   0.37, Val Acc:  90.84%, Time: 0:25:48
Epoch: 7
Iter:   2400, Train Loss:  0.014, Train Acc: 100.00%, Val Loss:   0.41, Val Acc:  90.38%, Time: 0:26:55
Iter:   2500, Train Loss:   0.14, Train Acc:  96.88%, Val Loss:   0.37, Val Acc:  91.22%, Time: 0:28:01
Iter:   2600, Train Loss:   0.11, Train Acc:  96.88%, Val Loss:   0.43, Val Acc:  89.76%, Time: 0:29:08
Iter:   2700, Train Loss:  0.089, Train Acc:  97.66%, Val Loss:   0.37, Val Acc:  91.18%, Time: 0:30:15
Epoch: 8
Iter:   2800, Train Loss: 0.0081, Train Acc: 100.00%, Val Loss:   0.44, Val Acc:  90.66%, Time: 0:31:22
Iter:   2900, Train Loss:  0.017, Train Acc: 100.00%, Val Loss:   0.44, Val Acc:  89.62%, Time: 0:32:29
Iter:   3000, Train Loss:  0.061, Train Acc:  96.88%, Val Loss:   0.43, Val Acc:  90.04%, Time: 0:33:36
No optimization for a long time, auto-stopping...
</code></pre>
<p>在验证集上的最佳效果为91.42%，经过了8轮迭代停止，速度相比CNN慢很多。</p>
<p>准确率和误差如图所示：</p>
<p><a href="https://github.com/gaussic/text-classification-cnn-rnn/blob/master/images/acc_loss_rnn.png" target="_blank"><img src="./GitHub - gaussic_text-classification-cnn-rnn_ CNN-RNN中文文本分类，基于tensorflow_files/acc_loss_rnn.png" alt="images" style="max-width:100%;"></a></p>
<h3><a href="https://github.com/gaussic/text-classification-cnn-rnn#测试-1" aria-hidden="true" class="anchor" id="user-content-测试-1"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>测试</h3>
<p>运行 <code>python run_rnn.py test</code> 在测试集上进行测试。</p>
<pre><code>Testing...
Test Loss:   0.21, Test Acc:  94.22%
Precision, Recall and F1-Score...
             precision    recall  f1-score   support

         体育       0.99      0.99      0.99      1000
         财经       0.91      0.99      0.95      1000
         房产       1.00      1.00      1.00      1000
         家居       0.97      0.73      0.83      1000
         教育       0.91      0.92      0.91      1000
         科技       0.93      0.96      0.94      1000
         时尚       0.89      0.97      0.93      1000
         时政       0.93      0.93      0.93      1000
         游戏       0.95      0.97      0.96      1000
         娱乐       0.97      0.96      0.97      1000

avg / total       0.94      0.94      0.94     10000

Confusion Matrix...
[[988   0   0   0   4   0   2   0   5   1]
 [  0 990   1   1   1   1   0   6   0   0]
 [  0   2 996   1   1   0   0   0   0   0]
 [  2  71   1 731  51  20  88  28   3   5]
 [  1   3   0   7 918  23   4  31   9   4]
 [  1   3   0   3   0 964   3   5  21   0]
 [  1   0   1   7   1   3 972   0   6   9]
 [  0  16   0   0  22  26   0 931   2   3]
 [  2   3   0   0   2   2  12   0 972   7]
 [  0   3   1   1   7   3  11   5   9 960]]
Time usage: 0:00:33
</code></pre>
<p>在测试集上的准确率达到了94.22%，且各类的precision, recall和f1-score，除了家居这一类别，都超过了0.9。</p>
<p>从混淆矩阵可以看出分类效果非常优秀。</p>
<p>对比两个模型，可见RNN除了在家居分类的表现不是很理想，其他几个类别较CNN差别不大。</p>
<p>还可以通过进一步的调节参数，来达到更好的效果。</p>
</article>
  </div>


  </div>
  <div class="modal-backdrop js-touch-events"></div>
</div>

    </div>
  </div>

  </div>

      
<div class="footer container-lg px-3" role="contentinfo">
  <div class="position-relative d-flex flex-justify-between py-6 mt-6 f6 text-gray border-top border-gray-light ">
    <ul class="list-style-none d-flex flex-wrap ">
      <li class="mr-3">© 2018 <span title="0.18779s from unicorn-4130551285-6z6ht">GitHub</span>, Inc.</li>
        <li class="mr-3"><a href="https://github.com/site/terms" data-ga-click="Footer, go to terms, text:terms">Terms</a></li>
        <li class="mr-3"><a href="https://github.com/site/privacy" data-ga-click="Footer, go to privacy, text:privacy">Privacy</a></li>
        <li class="mr-3"><a href="https://github.com/security" data-ga-click="Footer, go to security, text:security">Security</a></li>
        <li class="mr-3"><a href="https://status.github.com/" data-ga-click="Footer, go to status, text:status">Status</a></li>
        <li><a href="https://help.github.com/" data-ga-click="Footer, go to help, text:help">Help</a></li>
    </ul>

    <a href="https://github.com/" aria-label="Homepage" class="footer-octicon" title="GitHub">
      <svg aria-hidden="true" class="octicon octicon-mark-github" height="24" version="1.1" viewBox="0 0 16 16" width="24"><path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z"></path></svg>
</a>
    <ul class="list-style-none d-flex flex-wrap ">
        <li class="mr-3"><a href="https://github.com/contact" data-ga-click="Footer, go to contact, text:contact">Contact GitHub</a></li>
      <li class="mr-3"><a href="https://developer.github.com/" data-ga-click="Footer, go to api, text:api">API</a></li>
      <li class="mr-3"><a href="https://training.github.com/" data-ga-click="Footer, go to training, text:training">Training</a></li>
      <li class="mr-3"><a href="https://shop.github.com/" data-ga-click="Footer, go to shop, text:shop">Shop</a></li>
        <li class="mr-3"><a href="https://github.com/blog" data-ga-click="Footer, go to blog, text:blog">Blog</a></li>
        <li><a href="https://github.com/about" data-ga-click="Footer, go to about, text:about">About</a></li>

    </ul>
  </div>
</div>



  <div id="ajax-error-message" class="ajax-error-message flash flash-error">
    <svg aria-hidden="true" class="octicon octicon-alert" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M8.865 1.52c-.18-.31-.51-.5-.87-.5s-.69.19-.87.5L.275 13.5c-.18.31-.18.69 0 1 .19.31.52.5.87.5h13.7c.36 0 .69-.19.86-.5.17-.31.18-.69.01-1L8.865 1.52zM8.995 13h-2v-2h2v2zm0-3h-2V6h2v4z"></path></svg>
    <button type="button" class="flash-close js-ajax-error-dismiss" aria-label="Dismiss error">
      <svg aria-hidden="true" class="octicon octicon-x" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path fill-rule="evenodd" d="M7.48 8l3.75 3.75-1.48 1.48L6 9.48l-3.75 3.75-1.48-1.48L4.52 8 .77 4.25l1.48-1.48L6 6.52l3.75-3.75 1.48 1.48z"></path></svg>
    </button>
    You can't perform that action at this time.
  </div>


    
    <script crossorigin="anonymous" integrity="sha256-+xnpyXbt6GVODbcDcHIEoyLXhTRuY1OEN4fS1Kp+FA4=" src="./GitHub - gaussic_text-classification-cnn-rnn_ CNN-RNN中文文本分类，基于tensorflow_files/frameworks-fb19e9c976ede8654e0db703707204a322d785346e6353843787d2d4aa7e140e.js"></script>
    
    <script async="async" crossorigin="anonymous" integrity="sha256-UYMO+8DFvDojOCewqCRx/BYHPtm4ob5q8+EqnnhQ06I=" src="./GitHub - gaussic_text-classification-cnn-rnn_ CNN-RNN中文文本分类，基于tensorflow_files/github-51830efbc0c5bc3a233827b0a82471fc16073ed9b8a1be6af3e12a9e7850d3a2.js"></script>
    
    
    
    
  <div class="js-stale-session-flash stale-session-flash flash flash-warn flash-banner d-none">
    <svg aria-hidden="true" class="octicon octicon-alert" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M8.865 1.52c-.18-.31-.51-.5-.87-.5s-.69.19-.87.5L.275 13.5c-.18.31-.18.69 0 1 .19.31.52.5.87.5h13.7c.36 0 .69-.19.86-.5.17-.31.18-.69.01-1L8.865 1.52zM8.995 13h-2v-2h2v2zm0-3h-2V6h2v4z"></path></svg>
    <span class="signed-in-tab-flash">You signed in with another tab or window. <a href="https://github.com/gaussic/text-classification-cnn-rnn">Reload</a> to refresh your session.</span>
    <span class="signed-out-tab-flash">You signed out in another tab or window. <a href="https://github.com/gaussic/text-classification-cnn-rnn">Reload</a> to refresh your session.</span>
  </div>
  <div class="facebox" id="facebox" style="display:none;">
  <div class="facebox-popup">
    <div class="facebox-content" role="dialog" aria-labelledby="facebox-header" aria-describedby="facebox-description">
    </div>
    <button type="button" class="facebox-close js-facebox-close" aria-label="Close modal">
      <svg aria-hidden="true" class="octicon octicon-x" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path fill-rule="evenodd" d="M7.48 8l3.75 3.75-1.48 1.48L6 9.48l-3.75 3.75-1.48-1.48L4.52 8 .77 4.25l1.48-1.48L6 6.52l3.75-3.75 1.48 1.48z"></path></svg>
    </button>
  </div>
</div>


  


</body></html>